Here you can add some text if you want!
2+3
## [1] 5
In this case you obtain a result:
# state to the software what language we are using and if we want to run the code or not
2+3
## [1] 5
# language is r, if code should lead to the result or not (eval=T or F)
In this case you do not:
2+3
Using proper packages; the imageRy package has been built at Alma Mater for learning remote sensing:
library(imageRy)
Lets import some data by listing them in imageRy:
im.list()
## [1] "dolansprings_oli_2013088_canyon_lrg.jpg"
## [2] "EN_01.png"
## [3] "EN_02.png"
## [4] "EN_03.png"
## [5] "EN_04.png"
## [6] "EN_05.png"
## [7] "EN_06.png"
## [8] "EN_07.png"
## [9] "EN_08.png"
## [10] "EN_09.png"
## [11] "EN_10.png"
## [12] "EN_11.png"
## [13] "EN_12.png"
## [14] "EN_13.png"
## [15] "greenland.2000.tif"
## [16] "greenland.2005.tif"
## [17] "greenland.2010.tif"
## [18] "greenland.2015.tif"
## [19] "info.md"
## [20] "iss063e039892_lrg.jpg"
## [21] "matogrosso_ast_2006209_lrg.jpg"
## [22] "matogrosso_l5_1992219_lrg.jpg"
## [23] "NDVI_rainbow.png"
## [24] "NDVI_rainbow_legend.png"
## [25] "sentinel.dolomites.b2.tif"
## [26] "sentinel.dolomites.b3.tif"
## [27] "sentinel.dolomites.b4.tif"
## [28] "sentinel.dolomites.b8.tif"
## [29] "sentinel.png"
## [30] "Solar_Orbiter_s_first_views_of_the_Sun_pillars.jpg"
Importing the Mato Grosso area image and excluding warnings:
mato1992 <- im.import("matogrosso_l5_1992219_lrg.jpg")
In order to get information on the image, just type the name of the object:
mato1992
## class : SpatRaster
## dimensions : 1500, 1200, 3 (nrow, ncol, nlyr)
## resolution : 1, 1 (x, y)
## extent : 0, 1200, 0, 1500 (xmin, xmax, ymin, ymax)
## coord. ref. :
## source : matogrosso_l5_1992219_lrg.jpg
## colors RGB : 1, 2, 3
## names : matogrosso~2219_lrg_1, matogrosso~2219_lrg_2, matogrosso~2219_lrg_3
Making a new plot of the Mato Grosso area with the NIR on top of the green component of the RGB space:
im.plotRGB(mato1992, r=2, g=1, b=3)
Plotting several images altogether:
par(mfrow=c(2,2))
im.plotRGB(mato1992, r=1, g=2, b=3)
im.plotRGB(mato1992, r=2, g=1, b=3)
im.plotRGB(mato1992, r=3, g=2, b=1)
im.plotRGB(mato1992, r=2, g=1, b=1)
Calculating spectral indices:
library(terra)
## terra 1.7.55
library(viridis)
## Loading required package: viridisLite
dvi <- mato1992[[1]]-mato1992[[2]]
dvi
## class : SpatRaster
## dimensions : 1500, 1200, 1 (nrow, ncol, nlyr)
## resolution : 1, 1 (x, y)
## extent : 0, 1200, 0, 1500 (xmin, xmax, ymin, ymax)
## coord. ref. :
## source(s) : memory
## varname : matogrosso_l5_1992219_lrg
## name : matogrosso_l5_1992219_lrg_1
## min value : -246
## max value : 255
viridisc <- colorRampPalette(viridis(7))(255)
plot(dvi, col=viridisc)